package oop.constructor;

/**
 * Created with IntelliJ IDEA.
 * ClassName: Account
 * Package: oop.constructor
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-20
 * Time: 15:44
 */

//账户
public class Account {

    private int id;
    private double balance; //余额
    private double annualInterestRate; //年利率

    public Account(int i, double b, double a) {
        id = i;
        balance = b;
        annualInterestRate = a;
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    //取钱
    public void withdraw(double amount) {
        if (amount <= balance && amount > 0) {
            balance -= amount;
            System.out.println("成功取出: " + amount);
        } else {
            System.out.println("余额不足，取款失败");
        }
    }

    //存钱
    public void deposit(double amount) {
        if (amount > 0) {
            balance += amount;
            System.out.println("成功存入: " + amount);
        }
    }

}
